Creating Offline Web Applications in Macromedia Central
Table of Contents
Final Initiation
In the final bits of ActionScript, initiate a few more functions. You must let the Central Shell know that this is a Central application, which exposes your app to the Central API. You must also set up the initial states of the interface objects.
// initiate
function onActivate(shell) {
appShell = shell;
onNetworkChange(appShell.isConnected());
url_cbx.setEditable(true);
ctrl_btn.setIcon("icon_alert");
u_pfx = _url.substr(0, _url.lastIndexOf("/"));
initDisplay();
initCache();
}
function onDeactivate() {
// Save the LSO
_so.flush();
}
Central.initApplication(this, this);
product.xml and Installation
In the display function above, you may have noticed a reference to
load noimage.gif when the Central Shell is offline and asks for a URL
to cache or display. You're going to cache this image when a user installs
your application, so that regardless of the user's connection status,
your application will always be able to load the image. Using the file
tag and src attribute in the product.xml so that Central
knows to cache the file when it installs your app. The example source
on the first page of the article includes the noimage.gif file. Open
up Notepad or any text editor and save it as product.xml. I have pasted
the XML file contents below, bolding the relevant portions.
<product name="Cache Central"
created="1/22/2004"
version="1"
price="Free"
category="Other"
productID="CND100-063933-197221-612499">
<author name="Geoffrey Williams" info="http://www.gsolo.com/blog"/>
<description>Cache Files</description>
<application name="Cache Central"
src="offline_files.swf"
width="620" height="500"
lang="en"
background="#FFFFFF"
version="1">
<file src="noimage.gif"/>
</application>
</product>
Now you must put the applicable files on a web server and install your application.
- Place the files product.xml, noimage.gif, and offline_files.swf in a directory on your web server.
- Start Central and look at what you created.
- To install the application, go to the file menu and select Install Application from URL…
- Enter in the path to your product.xml file on your server and click Install.